from textblob import TextBlob
import nltk
# -*- coding:utf-8 -*-
import requests
import pandas as pd
import os
import json
from pyecharts.charts import WordCloud
from pyecharts import options as opts
from datetime import date
pd.set_option('display.max_columns', None)
#显示所有行
pd.set_option('display.max_rows', None)


if __name__ == '__main__':
    data1 = pd.read_csv("./data/cbc_1.csv")
    data2 = pd.read_csv("./data/ctv_1.csv")
    data3 = pd.read_csv("./data/post_1.csv")
    data4 = pd.read_csv("./data/toronto_1.csv")
    data5 = pd.read_csv("./data/globalnews_1.csv")
    data1["class"] = 'cbc'
    data2['class'] = 'ctv'
    data3['class'] = 'post'
    data4['class'] = 'toro'
    data5['class'] = 'glob'
    data = [data1, data2, data3, data4, data5]
    datas = pd.concat(data)
    datas.sort_values("publish_date", ascending=False, inplace=True)
    datas.index = range(len(datas))
    # data1["em"] = data1["content"].apply(lambda x:TextBlob(x).sentiment[0])
    # data2["em"] = data2["content"].apply(lambda x:TextBlob(x).sentiment[0])
    # data3["em"] = data3["content"].apply(lambda x:TextBlob(x).sentiment[0])
    # data4["em"] = data4["content"].apply(lambda x:TextBlob(x).sentiment[0])
    # data5["em"] = data5["content"].apply(lambda x:TextBlob(x).sentiment[0])
    datas["em"] = datas["content"].apply(lambda x:TextBlob(x).sentiment[0])
    datas.to_csv("./datas.csv", encoding='utf-8-sig', index=False)
    # data1.to_csv("./data1.csv", encoding='utf-8-sig', index=False)
    # data2.to_csv("./data2.csv", encoding='utf-8-sig', index=False)
    # data3.to_csv("./data3.csv", encoding='utf-8-sig', index=False)
    # data4.to_csv("./data4.csv", encoding='utf-8-sig', index=False)
    # data5.to_csv("./data5.csv", encoding='utf-8-sig', index=False)